﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc;
using ProjectManagement.Models;
using Projectmanagement.Utl;
using Projectmanagement.Entity;

namespace Projectmanagement.Controllers
{
    public class PrintingController : Controller
    {
        //
        // GET: /Printing/

        public ActionResult Index()
        {
            return View();
        }

        [GridAction]
        public ActionResult _SelectIndex(int? conferenceid)
        {
            return View(new GridModel(DQ.GetPrinting()));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _SaveAjaxEditing(int id, int? conferenceid)
        {
            var item = CH.GetDataByID<Printing>(id);
            if (TryUpdateModel(item))
            {
                CH.Edit<Printing>(item);
            }
            return View(new GridModel(DQ.GetPrinting()));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _InsertAjaxEditing(int? conferenceid)
        {
            var item = new Printing();

            if (TryUpdateModel(item))
            {
                CH.Create<Printing>(item);
            }
            return View(new GridModel(DQ.GetPrinting()));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _DeleteAjaxEditing(int id, int? conferenceid)
        {
            CH.Delete<Printing>(id);
            return View(new GridModel(DQ.GetPrinting()));
        }

    }
}
